package com.demo.thread;

public class ThreadTest{

	public static void main(String[] args) {
		ThreadDemo2 test=new ThreadDemo2("demo");
		Thread thread=new Thread(test);
		thread.start();
		ThreadDemo demo=new ThreadDemo();
		ThreadDemo demo2=new ThreadDemo();
		ThreadDemo demo3=new ThreadDemo();
		ThreadDemo demo4=new ThreadDemo();
		demo2.start();
		demo3.start();
		demo4.start();
		demo.start();
	}
	

}
	class ThreadDemo extends Thread{
		
		@Override
		public void run() {
			while(true){
				System.out.println("==============");
				try {
					sleep(1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
	class ThreadDemo2 implements Runnable {
		String name;
		ThreadDemo2(String name) {
			this.name=name;
		}
		public void run() {
			System.out.println(name+"-------");
		}
	}